﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using OpenAdmin.Application.Services;
using OpenAdmin.Application.Services.Dtos;
using OpenAdmin.Core.Consts;

namespace OpenAdmin.HttpApi.Controllers;

/// <summary>
/// 商品相关api
/// </summary>
[ApiController, Route("api/[controller]/[action]"), ApiExplorerSettings(GroupName = ApiGroupNameConsts.Mall)]
public class ProductController : ControllerBase
{
    private readonly ILogger<ProductController> _logger;
    private readonly IProductService _productService;
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="logger"></param>
    /// <param name="productService"></param>
    public ProductController(ILogger<ProductController> logger, IProductService productService)
    {
        _logger = logger;
        _productService = productService;
    }
    /// <summary>
    /// 获取商品列表
    /// </summary>
    /// <returns></returns>
    [HttpGet, ProducesResponseType(typeof(PagedList<ProductListByPageResponseDto>), 200)]
    public async Task<IActionResult> ProductListByPageAsync([FromQuery] ProductListByPageRequestDto requestDto)
    {
        return Ok(await _productService.ProductListByPageAsync(requestDto));
    }
}
